package com.ruoyi.manager.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.manager.mapper.SoldierSpecialCareMapper;
import com.ruoyi.manager.domain.SoldierSpecialCare;
import com.ruoyi.manager.service.ISoldierSpecialCareService;

/**
 * 优抚对象Service业务层处理
 *
 * @author Allen
 * @date 2021-08-31
 */
@Service
public class SoldierSpecialCareServiceImpl implements ISoldierSpecialCareService {
    @Autowired
    private SoldierSpecialCareMapper soldierSpecialCareMapper;

    /**
     * 查询优抚对象
     *
     * @param id
     *         优抚对象主键
     *
     * @return 优抚对象
     */
    @Override
    public SoldierSpecialCare selectSoldierSpecialCareById(Long id) {
        return soldierSpecialCareMapper.selectSoldierSpecialCareById(id);
    }

    /**
     * 查询优抚对象列表
     *
     * @param soldierSpecialCare
     *         优抚对象
     *
     * @return 优抚对象
     */
    @Override
    public List<SoldierSpecialCare> selectSoldierSpecialCareList(SoldierSpecialCare soldierSpecialCare) {
        return soldierSpecialCareMapper.selectSoldierSpecialCareList(soldierSpecialCare);
    }

    /**
     * 新增优抚对象
     *
     * @param soldierSpecialCare
     *         优抚对象
     *
     * @return 结果
     */
    @Override
    public int insertSoldierSpecialCare(SoldierSpecialCare soldierSpecialCare) {
        soldierSpecialCare.setCreateTime(DateUtils.getNowDate());
        return soldierSpecialCareMapper.insertSoldierSpecialCare(soldierSpecialCare);
    }

    /**
     * 修改优抚对象
     *
     * @param soldierSpecialCare
     *         优抚对象
     *
     * @return 结果
     */
    @Override
    public int updateSoldierSpecialCare(SoldierSpecialCare soldierSpecialCare) {
        return soldierSpecialCareMapper.updateSoldierSpecialCare(soldierSpecialCare);
    }

    /**
     * 批量删除优抚对象
     *
     * @param ids
     *         需要删除的优抚对象主键
     *
     * @return 结果
     */
    @Override
    public int deleteSoldierSpecialCareByIds(Long[] ids) {
        return soldierSpecialCareMapper.deleteSoldierSpecialCareByIds(ids);
    }

    /**
     * 删除优抚对象信息
     *
     * @param id
     *         优抚对象主键
     *
     * @return 结果
     */
    @Override
    public int deleteSoldierSpecialCareById(Long id) {
        return soldierSpecialCareMapper.deleteSoldierSpecialCareById(id);
    }

    @Override
    public int audit(Long id, Integer auditStatus) {
        SoldierSpecialCare soldierSpecialCare = new SoldierSpecialCare();
        soldierSpecialCare.setId(id);
        soldierSpecialCare.setAuditStatus(auditStatus);
        soldierSpecialCare.setAuditId(SecurityUtils.getUserId());
        return soldierSpecialCareMapper.updateSoldierSpecialCare(soldierSpecialCare);
    }
}
